/**
 * @param {number[]} nums
 * @return {number}
 */
var jump = function (nums) {
    let len = nums.length,
        curr = 0,
        next = 0,
        res =0
    for (let i = 0; i < len-1; i++) {
        next = Math.max(i+nums[i],next)
        if(i==curr){
            res++
            curr=next
        }
    }
    return res
};
console.log(jump([2,3,1,1,4]));